home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / comm / tcp / Amster-source.lha / Amster_Install / Source / hotlist.c < prev    next >
C/C++ Source or Header  |  2001-03-14  |  15KB  |  538 lines

  1. /*
  2. ** Amster - Hotlist
  3. ** Copyright © 2000-2001 by Jacob Laursen
  4. **
  5. ** This program is free software; you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation; either version 2 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. */
  19.  
  20. #include "amster.h"
  21.  
  22. #include <proto/dos.h>
  23. #include <proto/utility.h>
  24.  
  25. #include <MUI/Lamp_mcc.h>
  26. #include <MUI/NListview_mcc.h>
  27. #include <MUI/textinput_mcc.h>
  28.  
  29. #include "amster_Cat.h"
  30.  
  31. /* Global variables */
  32.  
  33. BOOL HotlistChanged = FALSE;
  34.  
  35. int browse_count = 0;
  36. int browse_state = 0;
  37.  
  38.  
  39. /* Private prototypes */
  40.  
  41. MUI_LIST_DISP_DECL(HotlistDisplay, struct HotlistEntry *entry);
  42. MUI_NLIST_COMP_DECL(HotlistCompare);
  43. MUI_LIST_DEST_DECL(HotlistDestruct, struct HotlistEntry *entry);
  44. void LoadHotlist(struct HotlistData *data);
  45. void SaveHotlist(struct HotlistData *data);
  46. void UploadHotlist(struct HotlistData *data);
  47. struct HotlistEntry *GetHotlistEntry(struct HotlistData *data, char *nick);
  48.  
  49.  
  50. MUI_DISPATCH(HotlistDispatch)
  51. {
  52.     struct HotlistData *data;
  53.  
  54.     switch (msg->MethodID) {
  55.         case OM_NEW:
  56.             return(HotlistNew(cl, obj, (APTR)msg));
  57.         case HOTLIST_LOAD:
  58.             data = INST_DATA(cl, obj);
  59.             LoadHotlist(data);
  60.             return NULL;
  61.         case HOTLIST_SAVE:
  62.             data = INST_DATA(cl, obj);
  63.             SaveHotlist(data);
  64.             return NULL;
  65.         case HOTLIST_UPLOAD:
  66.             data = INST_DATA(cl, obj);
  67.             UploadHotlist(data);
  68.             return NULL;
  69.         case HOTLIST_CLEAR:
  70.             data = INST_DATA(cl, obj);
  71.             DoMethod(data->LV_Search, RESULTVIEW_CLEAR, (((muimsg)msg)->arg1));
  72.             return NULL;
  73.         case HOTLIST_SIGNON:
  74.             {
  75.             long pos;
  76.             struct HotlistEntry *entry;
  77.  
  78.             data = INST_DATA(cl, obj);
  79.             if (entry = GetHotlistEntry(data, (char *)(((muimsg)msg)->arg1))) {
  80.                 entry->Online = 1;
  81.                 if ((int)(((muimsg)msg)->arg2) != entry->Speed) {
  82.                     entry->Speed = (int)(((muimsg)msg)->arg2);
  83.                     HotlistChanged = TRUE;
  84.                 }
  85.                 pos = MUIV_NList_GetPos_Start;
  86.                 DoMethod(data->LV_Hotlist, MUIM_NList_GetPos, entry, &pos);
  87.                 DoMethod(data->LV_Hotlist, MUIM_NList_Redraw, pos);
  88.                 DoMethod(data->LV_Hotlist, MUIM_NList_Sort);
  89.             }
  90.             return NULL;
  91.             }
  92.         case HOTLIST_SIGNOFF:
  93.             {
  94.             long pos;
  95.             struct HotlistEntry *entry;
  96.  
  97.             data = INST_DATA(cl, obj);
  98.             if (entry = GetHotlistEntry(data, (char *)(((muimsg)msg)->arg1))) {
  99.                 entry->Online = 0;
  100.                 pos = MUIV_NList_GetPos_Start;
  101.                 DoMethod(data->LV_Hotlist, MUIM_NList_GetPos, entry, &pos);
  102.                 DoMethod(data->LV_Hotlist, MUIM_NList_Redraw, pos);
  103.                 DoMethod(data->LV_Hotlist, MUIM_NList_Sort);
  104.             }
  105.             return NULL;
  106.             }
  107.         case HOTLIST_SIGNOFF_ALL:
  108.             {
  109.             int i;
  110.             struct HotlistEntry *entry;
  111.  
  112.             data = INST_DATA(cl, obj);
  113.             for (i=0; ; i++) {
  114.                 DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  115.                 if (!entry) break;
  116.                 entry->Online = 0;
  117.                 DoMethod(data->LV_Hotlist, MUIM_NList_Redraw, i);
  118.             }
  119.             return NULL;
  120.             }
  121.         case HOTLIST_ADD:
  122.             {
  123.             struct HotlistEntry *entry;
  124.             char *buf;
  125.             data = INST_DATA(cl, obj);
  126.  
  127.             if ((((muimsg)msg)->arg1)) buf = (char *)(((muimsg)msg)->arg1);
  128.             else get(data->ST_Nick, MUIA_String_Contents, &buf);
  129.             if (buf && buf[0] != '\0' && (entry = malloc(sizeof(struct HotlistEntry)))) {
  130.                 entry->Online = 0;
  131.                 entry->Speed = 0;
  132.                 entry->Nick = strdup(buf);
  133.  
  134.                 DoMethod(data->LV_Hotlist, MUIM_NList_InsertSingle, entry, MUIV_NList_Insert_Sorted);
  135.                 if (gui_onlinestate == ONLINE) nap_sendbuf(NAPC_HOTLIST_ADD, entry->Nick);
  136.                 HotlistChanged = TRUE;
  137.             }
  138.             if (!(((muimsg)msg)->arg1)) set(data->ST_Nick, MUIA_String_Contents, "");
  139.             }
  140.             return NULL;
  141.         case HOTLIST_REMOVE:
  142.             {
  143.             struct HotlistEntry *entry;
  144.             data = INST_DATA(cl, obj);
  145.  
  146.             DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &entry);
  147.             if (entry && gui_onlinestate == ONLINE) nap_sendbuf(NAPC_HOTLIST_REMOVE, entry->Nick);
  148.  
  149.             DoMethod(data->LV_Hotlist, MUIM_NList_Remove, MUIV_NList_Remove_Active);
  150.             HotlistChanged = TRUE;
  151.             return NULL;
  152.             }
  153.         case HOTLIST_BROWSE:
  154.             {
  155.             struct HotlistEntry *entry;
  156.             long showresults;
  157.             data = INST_DATA(cl, obj);
  158.  
  159.             get(data->TG_Results, MUIA_Selected, &showresults);
  160.             if (!showresults) {
  161.                 set(data->LV_Search, MUIA_ShowMe, TRUE);
  162.                 set(data->TG_Results, MUIA_Selected, TRUE);
  163.             }
  164.  
  165.             DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &entry);
  166.             if (entry) DoMethod(data->LV_Search, RESULTVIEW_NICK, entry->Nick);
  167.  
  168.             return NULL;
  169.             }
  170.         case HOTLIST_NICK:
  171.             {
  172.             u_long tmp;
  173.             data = INST_DATA(cl, obj);
  174.  
  175.             get(obj, MUIA_Window_Open, &tmp);
  176.             if (!tmp) set(obj, MUIA_Window_Open, TRUE);
  177.             /* Open the window if it's not already opened */
  178.  
  179.             get(data->TG_Results, MUIA_Selected, &tmp);
  180.             if (!tmp) {
  181.                 set(data->LV_Search, MUIA_ShowMe, TRUE);
  182.                 set(data->TG_Results, MUIA_Selected, TRUE);
  183.             }
  184.  
  185.             if ((char *)(((muimsg)msg)->arg1) == NULL) {
  186.                 GetAttr(MUIA_String_Contents, data->ST_Nick, &tmp);
  187.                 if (tmp && ((char *)tmp)[0] != '\0') DoMethod(data->LV_Search, RESULTVIEW_NICK, (char *)tmp);
  188.             }
  189.             else DoMethod(data->LV_Search, RESULTVIEW_NICK, (char *)(((muimsg)msg)->arg1));
  190.             return NULL;
  191.             }
  192.         case HOTLIST_FOUND:
  193.             data = INST_DATA(cl, obj);
  194.             DoMethod(data->LV_Search, RESULTVIEW_FOUND, ((muimsg)msg)->arg1);
  195.             return NULL;
  196.         case HOTLIST_TOGGLE_RESULTS:
  197.             {
  198.             u_long tmp;
  199.             data = INST_DATA(cl, obj);
  200.  
  201.             GetAttr(MUIA_Selected, data->TG_Results, &tmp);
  202.             if (tmp)
  203.                 set(data->LV_Search, MUIA_ShowMe, TRUE);
  204.             else
  205.                 set(data->LV_Search, MUIA_ShowMe, FALSE);
  206.             return NULL;
  207.             }
  208.         case HOTLIST_TOGGLE:
  209.             data = INST_DATA(cl, obj);
  210.             DoMethod(data->LV_Search, RESULTVIEW_TOGGLE_ONE);
  211.             return NULL;
  212.     }
  213.  
  214.     return(DoSuperMethodA(cl, obj, msg));
  215. }
  216.  
  217.  
  218. ULONG HotlistNew(struct IClass *cl, Object *obj, struct opSet *msg)
  219. {
  220.     static const struct Hook HotlistDispHook = { {NULL, NULL}, &HotlistDisplay,   NULL, NULL };
  221.     static const struct Hook HotlistCompHook = { {NULL, NULL}, &HotlistCompare,   NULL, NULL };
  222.     static const struct Hook HotlistDestHook = { {NULL, NULL}, &HotlistDestruct,  NULL, NULL };
  223.  
  224.     struct HotlistData *data;
  225.  
  226.     Object *LV_Hotlist, *LV_Search;
  227.     Object *BT_Add, *BT_Remove;
  228.     Object *ST_Nick, *BT_Browse;
  229.     Object *TG_Results;
  230.  
  231.     gColFormat = "COL=1 BAR, COL=2 BAR, COL=3 BAR, COL=4 BAR, COL=5 BAR, COL=6 BAR";
  232.  
  233.     if (obj = (Object *)DoSuperNew(cl, obj,
  234.         MUIA_HelpNode, "hotlist",
  235.         MUIA_Window_Title, MSG_HOTLIST_TITLE,
  236.         MUIA_Window_ID, MAKE_ID('H','O','T','L'),
  237.         WindowContents, HGroup,
  238.             Child, VGroup,
  239.                 MUIA_HorizWeight, 25,
  240.                 Child, NListviewObject,
  241.                     MUIA_NListview_NList, LV_Hotlist = NListObject,
  242.                         InputListFrame,
  243.                         MUIA_NList_ListBackground, MUII_ListBack,
  244.                         MUIA_NList_Title, TRUE,
  245.                         MUIA_NList_Format, "BAR,BAR,",
  246.                         MUIA_NList_DisplayHook, &HotlistDispHook,
  247.                         MUIA_NList_CompareHook2, &HotlistCompHook,
  248.                         MUIA_NList_DestructHook, &HotlistDestHook,
  249.                     End,
  250.                 End,
  251.                 Child, HGroup,
  252.                     Child, Label2(MSG_SEARCHUSER),
  253.                     Child, ST_Nick = TextinputObject,
  254.                         StringFrame,
  255.                         MUIA_Textinput_Multiline, FALSE,
  256.                         MUIA_HorizWeight, 400,
  257.                         MUIA_String_MaxLen, 20,
  258.                         MUIA_CycleChain, 1,
  259.                         MUIA_ShortHelp, MSG_SEARCHUSER_HELP,
  260.                     End,
  261.                 End,
  262.                 Child, HGroup,
  263.                     Child, BT_Add    = SimpleButton(MSG_HOTLIST_ADD_GAD),
  264.                     Child, BT_Remove = SimpleButton(MSG_HOTLIST_REMOVE_GAD),
  265.                     Child, BT_Browse = SimpleButton(MSG_SEARCHUSER_GAD),
  266.                 End,
  267.                 Child, HGroup,
  268.                     Child, TextObject,
  269.                         MUIA_HorizWeight, 25,
  270.                         MUIA_Text_PreParse, "\33r",
  271.                         MUIA_Text_Contents, MSG_HOTLIST_RESULTS,
  272.                     End,
  273.                     Child, TG_Results = ImageObject,
  274.                         ButtonFrame,
  275.                         MUIA_HorizWeight, 10,
  276.                         MUIA_Background, MUII_ButtonBack,
  277.                         MUIA_InputMode, MUIV_InputMode_Toggle,
  278.                         MUIA_ShowSelState, FALSE,
  279.                         MUIA_Image_Spec, "6:15",
  280.                         MUIA_Selected, FALSE,
  281.                     End,
  282.                 End,
  283.             End,
  284.             Child, BalanceObject, End,
  285.             Child, LV_Search = NewObject(gui->resultview_mcc->mcc_Class, NULL, MUIA_Amster_ContextMenu, FALSE, TAG_DONE),
  286.         End,
  287.         TAG_MORE, msg->ops_AttrList))
  288.     {
  289.         data = INST_DATA(cl, obj);
  290.         data->LV_Hotlist = LV_Hotlist;
  291.         data->LV_Search  = LV_Search;
  292.         data->TG_Results = TG_Results;
  293.         data->ST_Nick    = ST_Nick;
  294.  
  295.         lamp_useinlist(LV_Hotlist);
  296.  
  297.         DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, obj, 3, MUIM_Set, MUIA_Window_Open, FALSE);
  298.  
  299.         DoMethod(BT_Add,    MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, HOTLIST_ADD);
  300.         DoMethod(BT_Remove, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, HOTLIST_REMOVE);
  301.         DoMethod(BT_Browse, MUIM_Notify, MUIA_Pressed, FALSE, obj, 2, HOTLIST_NICK, NULL);
  302.         DoMethod(ST_Nick,   MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, obj, 2, HOTLIST_NICK, NULL);
  303.  
  304.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_DoubleClick, MUIV_EveryTime, obj, 1, HOTLIST_BROWSE);
  305.         DoMethod(TG_Results, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, obj, 1, HOTLIST_TOGGLE_RESULTS);
  306.  
  307.         LoadHotlist(data);
  308.  
  309.         /* Default sort */
  310.  
  311.         DoMethod(LV_Hotlist, MUIM_Set, MUIA_NList_TitleMark, 1);
  312.         DoMethod(LV_Hotlist, MUIM_NList_Sort3, 1, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  313.  
  314.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_TitleClick,  MUIV_EveryTime, LV_Hotlist, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  315.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_TitleClick2, MUIV_EveryTime, LV_Hotlist, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
  316.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_SortType,    MUIV_EveryTime, LV_Hotlist, 3, MUIM_Set, MUIA_NList_TitleMark,  MUIV_TriggerValue);
  317.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_SortType2,   MUIV_EveryTime, LV_Hotlist, 3, MUIM_Set, MUIA_NList_TitleMark2, MUIV_TriggerValue);
  318.  
  319.         set(data->LV_Search, MUIA_ShowMe, FALSE);
  320.  
  321.         return((ULONG)obj);
  322.     }
  323.     return(0);
  324. }
  325.  
  326.  
  327. MUI_LIST_DISP(HotlistDisplay, struct HotlistEntry *entry)
  328. {
  329.     if (entry) {
  330.         *array++ = entry->Nick;
  331.         if (entry->Online) *array++ = "\33bOnline";
  332.         else *array++ = "Offline";
  333. /*
  334.         if (entry->Online) *array++ = lamp_getforlist(4);
  335.         else *array++ = lamp_getforlist(2);
  336. */
  337.         *array = nap_linktype[entry->Speed];
  338.     }
  339.     else {
  340.         *array++ = (char *)MSG_HOTLIST_NICK;
  341.         *array++ = (char *)MSG_HOTLIST_STATUS;
  342.         *array   = (char *)MSG_HOTLIST_LINK;
  343.     }
  344.  
  345.     return NULL;
  346. }
  347.  
  348.  
  349. MUI_NLIST_COMP(HotlistCompare)
  350. {
  351.     struct HotlistEntry *entry1 = ncm->entry1;
  352.     struct HotlistEntry *entry2 = ncm->entry2;
  353.     LONG col1 = ncm->sort_type & MUIV_NList_TitleMark_ColMask;
  354.     LONG col2 = ncm->sort_type2 & MUIV_NList_TitleMark2_ColMask;
  355.     ULONG result = 0;
  356.  
  357.     if (ncm->sort_type == MUIV_NList_SortType_None) return (0);
  358.  
  359.     if (col1 == 0) {
  360.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  361.             result = (LONG) stricmp(entry2->Nick, entry1->Nick);
  362.         else
  363.             result = (LONG) stricmp(entry1->Nick, entry2->Nick);
  364.     }
  365.     else if (col1 == 1) {
  366.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  367.             result = entry1->Online - entry2->Online;
  368.         else
  369.             result = entry2->Online - entry1->Online;
  370.     }
  371.     else if (col1 == 2) {
  372.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  373.             result = entry2->Speed - entry1->Speed;
  374.         else
  375.             result = entry1->Speed - entry2->Speed;
  376.     }
  377.  
  378.     if ((result != 0) || (col1 == col2)) return (result);
  379.  
  380.     if (col2 == 0) {
  381.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  382.             result = (LONG) stricmp(entry2->Nick, entry1->Nick);
  383.         else
  384.             result = (LONG) stricmp(entry1->Nick, entry2->Nick);
  385.     }
  386.     else if (col2 == 1) {
  387.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  388.             result = entry1->Online - entry2->Online;
  389.         else
  390.             result = entry2->Online - entry1->Online;
  391.     }
  392.     else if (col2 == 2) {
  393.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  394.             result = entry2->Speed - entry1->Speed;
  395.         else
  396.             result = entry1->Speed - entry2->Speed;
  397.     }
  398.  
  399.     return (result);
  400. }
  401.  
  402.  
  403. MUI_LIST_DEST(HotlistDestruct, struct HotlistEntry *entry)
  404. {
  405.     free(entry);
  406.     return NULL;
  407. }
  408.  
  409.  
  410. void LoadHotlist(struct HotlistData *data)
  411. {
  412.     BPTR fh;
  413.     char buf[1024];
  414.     int line = 0;
  415.     struct HotlistEntry *entry;
  416.     LONG argarray[] = { NULL, NULL };
  417.     UBYTE *argstr = "NICK/K/A,SPEED/K/N";
  418.     struct RDArgs *rdargs;
  419.  
  420.     if (fh = Open("PROGDIR:Amster.hotlist", MODE_OLDFILE)) {
  421.         set(data->LV_Hotlist, MUIA_NList_Quiet, MUIV_NList_Quiet_Full);
  422.         if (rdargs = AllocDosObject(DOS_RDARGS, NULL)) {
  423.             while (FGets(fh, buf, sizeof(buf))) {
  424.                 line++;
  425.  
  426.                 rdargs->RDA_Buffer = NULL;
  427.                 rdargs->RDA_Source.CS_Buffer = buf;
  428.                 rdargs->RDA_Source.CS_Length = strlen(buf);
  429.                 rdargs->RDA_Source.CS_CurChr = 0;
  430.                 argarray[1] = NULL;
  431.  
  432.                 if (ReadArgs(argstr, argarray, rdargs)) {
  433.                     if (entry = malloc(sizeof(struct HotlistEntry))) {
  434.                         entry->Nick = strdup((char *)argarray[0]);
  435.                         if (argarray[1]) entry->Speed = *((long *)argarray[1]);
  436.                         else entry->Speed = 0;
  437.                         entry->Online = 0;
  438.                         DoMethod(data->LV_Hotlist, MUIM_NList_InsertSingle, entry, TAG_DONE);
  439.  
  440.                         if (gui_onlinestate == ONLINE) nap_sendbuf(NAPC_HOTLIST_INIT, entry->Nick);
  441.                     }
  442.                     FreeArgs(rdargs);
  443.                 }
  444.                 else gui_debugf((char *)MSG_PARSE_ERROR, "PROGDIR:Amster.hotlist", line);
  445.             }
  446.             FreeDosObject(DOS_RDARGS, rdargs);
  447.         }
  448.         set(data->LV_Hotlist, MUIA_NList_Quiet, MUIV_NList_Quiet_None);
  449.         Close(fh);
  450.         DoMethod(data->LV_Hotlist, MUIM_NList_Sort);
  451.     }
  452. }
  453.  
  454.  
  455. void SaveHotlist(struct HotlistData *data)
  456. {
  457.     struct HotlistEntry *entry;
  458.     BPTR fh;
  459.     char buf[1024];
  460.     int i;
  461.  
  462.     fh = Open("PROGDIR:Amster.hotlist", MODE_NEWFILE);
  463.     if (!fh) return;
  464.  
  465.     for (i=0; ; i++) {
  466.         DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  467.         if (!entry) break;
  468.         sprintf(buf, "NICK \"%s\" SPEED %d\n", entry->Nick, entry->Speed);
  469.         Write(fh, buf, strlen(buf)); /* Should be buffered, check FWrite */
  470.     }
  471.  
  472.     Close(fh);
  473.     HotlistChanged = FALSE;
  474. }
  475.  
  476.  
  477. void UploadHotlist(struct HotlistData *data)
  478. {
  479.     struct HotlistEntry *entry;
  480.     int i;
  481.  
  482.     if (gui_onlinestate < LOGGING_IN) return;
  483.  
  484.     for (i=0; ; i++) {
  485.         DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  486.         if (!entry) break;
  487.         nap_sendbuf(NAPC_HOTLIST_INIT, entry->Nick);;
  488.     }
  489. }
  490.  
  491.  
  492. void HotlistInterpret(u_int com, char *data)
  493. {
  494.     char *nick;
  495.     int speed;
  496.  
  497.     switch(com) {
  498.         case NAPC_USER_SIGNON:
  499.             nick = nap_token(&data);
  500.             speed = atoi(data);
  501.             if (speed < 0 || speed > 10) speed = 0;
  502. #ifdef AMSTER_DEBUG
  503. gui_debugf("user signon: %s, speed: %ld", nick, speed);
  504. #endif
  505.             DoMethod(gui->WI_Hotlist, HOTLIST_SIGNON, nick, speed);
  506.             break;
  507.         case NAPC_USER_SIGNOFF:
  508. gui_debugf((char *)MSG_INFO_SIGNOFF, data);
  509.             DoMethod(gui->WI_Hotlist, HOTLIST_SIGNOFF, data);
  510.             break;
  511.         case NAPC_HOTLIST_ACK:
  512. #ifdef AMSTER_DEBUG
  513. gui_debugf("user %s succesfully added to hotlist", data);
  514. #endif
  515.             break;
  516.         case NAPC_HOTLIST_ERROR:
  517. #ifdef AMSTER_DEBUG
  518. gui_debugf("error adding %s to hotlist", data);
  519. #endif
  520.             break;
  521.     }
  522. }
  523.  
  524.  
  525. struct HotlistEntry *GetHotlistEntry(struct HotlistData *data, char *nick)
  526. {
  527.     struct HotlistEntry *entry;
  528.     int i;
  529.  
  530.     for (i=0; ; i++) {
  531.         DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  532.         if (!entry) return NULL;
  533.         if (stricmp(entry->Nick, nick) == 0) break;
  534.     }
  535.  
  536.     return entry;
  537. }
  538.